package com.chen.TestDealNullSiwftCode;

import java.awt.Container;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

/**
 *@author：email: <a href="cyb@ewppay.com"> Administrator </a> 
 *@Date 2017-2-10 下午2:21:12 
 */

public class TestFrame extends JFrame implements ActionListener{
	JButton btn = new JButton("处理");
	JTextField urlTextField = new JTextField();
	JTextField usernameTextField = new JTextField();
	JTextField passwordTextField = new JTextField();
	JTextField resultTextField = new JTextField();
	
	public TestFrame(){
		JPanel contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5,5,5,5));
		this.setContentPane(contentPane);
		contentPane.setLayout(new GridLayout(5,1,5,5));
		JPanel pane1 = new JPanel();
		contentPane.add(pane1);
		JPanel pane2 = new JPanel();
		contentPane.add(pane2);
		JPanel pane3 = new JPanel();
		contentPane.add(pane3);
		JPanel pane4 = new JPanel();
		contentPane.add(pane4);
		JPanel pane5 = new JPanel();
		contentPane.add(pane5);
		
		JLabel urlLabel = new JLabel("URL:");
		urlTextField.setColumns(20);
		pane1.add(urlLabel);
		pane1.add(urlTextField);
		
		JLabel usernameLabel = new JLabel("username");
		usernameTextField.setColumns(10);
		pane2.add(usernameLabel);
		pane2.add(usernameTextField);
		
		
		JLabel passwordLabel = new JLabel("password");
		passwordTextField.setColumns(10);
		pane3.add(passwordLabel);
		pane3.add(passwordTextField);
		
		btn.addActionListener(this);
		pane4.add(btn);
		
		resultTextField.setColumns(10);
		pane5.add(resultTextField);
		
		this.setSize(300, 200);
		this.setTitle("处理空行号的银行卡");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}
	
	
		public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable(){

			@Override
			public void run() {
				TestFrame frame = new TestFrame();
			}
			
		});
	}


		@Override
		public void actionPerformed(ActionEvent e) {
			if(e.getSource() == btn){
				resultTextField.setText("开始处理------");
				long start = System.currentTimeMillis();
				String url = urlTextField.getText();
				String username = usernameTextField.getText();
				String password = passwordTextField.getText();
				DBTest t = new DBTest(url,username,password);
				t.dealNullSwiftCodeList();
				System.out.println("url:" + urlTextField.getText());
				resultTextField.setText("处理完成,cost = " + (System.currentTimeMillis() - start) + " ms!");
			}
		}
}
